package GUI;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.WindowConstants;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
@SuppressWarnings("rawtypes")
public class TamanioTablero extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = -3394793490528062194L;
	private JLabel tituloTamanio;
	private JButton crearTablero;
	private JRadioButton com;
	private JComboBox dificultad;
	private JLabel titulo3;
	private JLabel titulo2;
	private JRadioButton oponente;
	private PanelConFondo2 fondo;
	private JComboBox dimensiones;
	private JButton cancelar;
	private int dif;
	private int mj;

	/**
	 * Auto-generated main method to display this JFrame
	 */

	public TamanioTablero() {
		super();
		initGUI();
	}

	@SuppressWarnings("unchecked")
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Tablero");
			getContentPane().setLayout(null);

			{
				fondo = new PanelConFondo2();
				getContentPane().add(fondo);
				fondo.setBounds(0, 0, 349, 280);
				fondo.setLayout(null);
				{
					tituloTamanio = new JLabel();
					fondo.add(tituloTamanio);
					tituloTamanio.setText("Dimension");
					tituloTamanio.setBounds(27, 42, 80, 16);
					tituloTamanio.setForeground(new java.awt.Color(0, 0, 0));
					tituloTamanio.setFont(new java.awt.Font("Segoe UI", 1, 12));
				}
				{
					crearTablero = new JButton();
					fondo.add(crearTablero);
					crearTablero.setText("Ok");
					crearTablero.setBounds(62, 211, 107, 23);
					crearTablero.addActionListener(new ActionListener() {
						@Override
						public void actionPerformed(ActionEvent e) {
							if (mj == 1) {
								TableroOponente t = new TableroOponente(Integer
										.parseInt(dimensiones.getSelectedItem()
												.toString().split(" ")[0]));
								t.setLocationRelativeTo(null);
								t.setVisible(true);
							}
							if(mj == 2){
								TableroVirtual t = new TableroVirtual(Integer
										.parseInt(dimensiones.getSelectedItem()
												.toString().split(" ")[0]),dif);
								t.setLocationRelativeTo(null);
								t.setVisible(true);							
							}
							
						}
					});
				}
				{
					cancelar = new JButton();
					fondo.add(cancelar);
					cancelar.setText("Cancelar");
					cancelar.setBounds(180, 211, 107, 23);
					cancelar.addActionListener(new ActionListener() {
						@Override
						public void actionPerformed(ActionEvent e) {
							dispose();
						}
					});
				}
				{
					ComboBoxModel dimensionesModel = new DefaultComboBoxModel(
							new String[] { "3 x 3", "4 x 4", "5 x 5", "6 x 6",
									"7 x 7", "8 x 8", "9 x 9", "10 x 10",
									"11 x 11", "12 x 12", "13 x 13", "14 x 14",
									"15 x 15" });
					dimensiones = new JComboBox();
					fondo.add(dimensiones);
					dimensiones.setModel(dimensionesModel);
					dimensiones.setBounds(114, 35, 77, 23);
				}
				{
					oponente = new JRadioButton();
					fondo.add(oponente);
					oponente.setText("VS Oponente");
					oponente.setBounds(48, 117, 121, 19);
					oponente.addActionListener(new ActionListener() {

						@Override
						public void actionPerformed(ActionEvent e) {
							com.setSelected(false);
							dificultad.setEnabled(false);
							mj = 1;
							dif = 0;
						}
					});
				}
				{
					com = new JRadioButton();
					fondo.add(com);
					com.setText("VS COM");
					com.setBounds(180, 117, 121, 19);
					com.addActionListener(new ActionListener() {
						@Override
						public void actionPerformed(ActionEvent e) {
							oponente.setSelected(false);
							dificultad.setEnabled(true);
							mj = 2;
							dif = dificultad.getSelectedIndex() + 1;
						}
					});
				}
				{
					titulo2 = new JLabel();
					fondo.add(titulo2);
					titulo2.setText("Dificultad");
					titulo2.setBounds(29, 161, 98, 16);
					titulo2.setFont(new java.awt.Font("Serif", 1, 12));
				}
				{
					ComboBoxModel dificultadModel = new DefaultComboBoxModel(
							new String[] { "Principiante", "Avanzado" });
					dificultad = new JComboBox();
					fondo.add(dificultad);
					dificultad.setModel(dificultadModel);
					dificultad.setBounds(117, 155, 138, 22);
				}
				{
					titulo3 = new JLabel();
					fondo.add(titulo3);
					titulo3.setText("Modo de Juego");
					titulo3.setBounds(27, 93, 117, 15);
					titulo3.setFont(new java.awt.Font("Serif", 1, 12));
				}
			}
			pack();
			this.setSize(349, 306);
			this.setResizable(false);
		} catch (Exception e) {
			// add your error handling code here
			e.printStackTrace();
		}
	}

}